Skip to content

Enhance p5.strands noise() to support noise(x, y) and 4-octave fractal noise #7964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025

Conversation

LalitNarayanYadav
Copy link
Contributor

Summary

This PR improves the noise() function in p5.strands by aligning it more closely with core p5.js functionality and improving its visual quality through fractal noise.


What's Included

  • noise(x, y) is now supported in addition to noise([x, y])
  • Added 4-octave fractal noise implementation in GLSL
  • noiseGLSL.glsl injected into both vertex and fragment stages
  • Falls back to the original p5.js noise() function outside of strands
  • MIT license attribution added for the noise basis function

Technical Notes

  • The fn.noise() wrapper checks for 2 arguments and wraps them using vec2(...) to allow for noise(x, y) syntax.
  • The GLSL file noiseGLSL.glsl defines baseNoise() and a new noise() function using a fixed 4-octave loop:
    for (int i = 0; i < 4; i++) {
      result += amplitude * baseNoise(st * frequency);
      frequency *= 2.0;
      amplitude *= 0.5;
    }
    
    

PR Checklist

@LalitNarayanYadav
Copy link
Contributor Author

fixes #7897

@LalitNarayanYadav
Copy link
Contributor Author

Hi @davepagurek! I’ve pushed the updated changes:

  • noise(x, y) is now supported alongside noise(vec2)
  • The GLSL noise function now uses 4 octaves for smoother fractal noise
  • Declarations are added to both vertex and fragment stages
  • Falls back to original p5.js noise outside of strands

Let me know if anything needs adjustment.

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, just got back from vacation! just tested it out, works great!

@davepagurek davepagurek merged commit 53355a7 into processing:dev-2.0 Jul 16, 2025
2 checks passed
@LalitNarayanYadav
Copy link
Contributor Author

LalitNarayanYadav commented Jul 17, 2025

Sorry for the delay, just got back from vacation! just tested it out, works great!

No worries at all, hope you had a great vacation! 😊
Thanks a lot for reviewing and merging it, glad it worked well!
Would love to keep contributing to p5.strands ✨

@davepagurek
Copy link
Contributor

Thanks @LalitNarayanYadav! I suppose the next task would be to see if we can support 3D noise?

@LalitNarayanYadav
Copy link
Contributor Author

LalitNarayanYadav commented Jul 17, 2025

That sounds great, @davepagurek . I’d love to work on adding support for 3D noise next!
I'll start by looking into how we can generalize the current 2D implementation and integrate noise(vec3) similarly. Will share progress soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants